package com.example.demo;

import com.example.demo.Bean.Pet;
import com.example.demo.Config.MyConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import javax.security.auth.login.Configuration;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext ioc =  SpringApplication.run(DemoApplication.class, args);//返回一个IOC容器
        String[] names = ioc.getBeanDefinitionNames();
        for (String name : names) {
            //System.out.println(name);
        }
        Pet nene = ioc.getBean("pet01",Pet.class);
        Pet nana = ioc.getBean("pet01",Pet.class);
        System.out.println(nene == nana);
        MyConfig myConfig = ioc.getBean(MyConfig.class);
        Pet nene01 = myConfig.pet01();
        Pet nene02 = myConfig.pet01();
        System.out.println(nene01 == nene02);
    }
}
